package glossos.tree.snapshot;

import glossos.tree.Node;

import org.apache.log4j.Logger;
import org.jmock.api.Invocation;
import org.jmock.api.Invokable;

public class NodeProxy implements Invokable {
	private static Logger logger = Logger.getLogger(NodeProxy.class);
    private NodeRepository nodeRepository;
    private Long id;

    public NodeProxy(NodeRepository nodeRepository, Long id) {
        this.nodeRepository = nodeRepository;
        this.id = id;
    }

    public Object invoke(Invocation invocation) throws Throwable {
        Node node = nodeRepository.findById(id);
        return invocation.getInvokedMethod().invoke(node, invocation.getParametersAsArray());
    }
}
